package it.low.game.server.persistence;

import it.low.game.core.element.ActiveElement;

import java.util.HashMap;
import java.util.Map;

public class ServerStoring {

	private static Map<Long, ActiveElement> elementPlayers = new HashMap<Long, ActiveElement>();
	private static Map<Long, ActiveElement> elementBots = new HashMap<Long, ActiveElement>();
	
	// LOAD BACKGROUND IMAGES
	private static String bgImage_ground_0_C = new String("images/map/background/ground_0.jpg");
	private static String bgImage_ground_1_N = new String("images/map/background/ground_1_N.jpg");
	private static String bgImage_ground_1_S = new String("images/map/background/ground_1_S.jpg");
	
	private static String[][] mapDescription = null;
	
	public static void init(){
		// INIZIALIZZAZIONE DELLA MAPPA
		mapDescription = new String[3][4];		
		mapDescription[0][0] = bgImage_ground_1_N;
		mapDescription[1][0] = bgImage_ground_1_N;
		mapDescription[2][0] = bgImage_ground_1_N;
		mapDescription[0][1] = bgImage_ground_0_C;			
		mapDescription[1][1] = bgImage_ground_0_C;
		mapDescription[2][1] = bgImage_ground_0_C;
		mapDescription[0][2] = bgImage_ground_0_C;			
		mapDescription[1][2] = bgImage_ground_0_C;
		mapDescription[2][2] = bgImage_ground_0_C;
		mapDescription[0][3] = bgImage_ground_1_S;			
		mapDescription[1][3] = bgImage_ground_1_S;
		mapDescription[2][3] = bgImage_ground_1_S;
		
		// INIZIALIZZAZIONE DEI BOT
		String botImg = "images/map/bot/monster.png";
		
		double movSpeed = 0.04;
		double runSpeed = 0.07;
		double sigRange = 200;
		double attRange = 100;
		
		ActiveElement bot1 = new ActiveElement(1001,"Monster1",botImg);
		bot1.setProperty(ActiveElement.MOV_SPEED, movSpeed);
		bot1.setProperty(ActiveElement.RUN_SPEED, runSpeed);
		bot1.setProperty(ActiveElement.SIG_RANGE, sigRange);
		bot1.setProperty(ActiveElement.ATT_RANGE, attRange);
						
		ActiveElement bot2 = new ActiveElement(1002,"Monster2",botImg);		
		bot2.setProperty(ActiveElement.MOV_SPEED, movSpeed);
		bot2.setProperty(ActiveElement.RUN_SPEED, runSpeed);
		bot2.setProperty(ActiveElement.SIG_RANGE, sigRange);
		bot2.setProperty(ActiveElement.ATT_RANGE, attRange);
				
		ActiveElement bot3 = new ActiveElement(1003,"Monster3",botImg);		
		bot3.setProperty(ActiveElement.MOV_SPEED, movSpeed);
		bot3.setProperty(ActiveElement.RUN_SPEED, runSpeed);
		bot3.setProperty(ActiveElement.SIG_RANGE, sigRange);
		bot3.setProperty(ActiveElement.ATT_RANGE, attRange);
				
		// INIZIALIZZAZIONE DEI PLAYERS
		ActiveElement player1 = new ActiveElement(1,"Axel","images/player/hero.png");
		player1.setProperty(ActiveElement.MOV_SPEED, 0.1);
		player1.setProperty(ActiveElement.RUN_SPEED, 0.1);
		player1.setProperty(ActiveElement.SIG_RANGE, 200);
		player1.setProperty(ActiveElement.ATT_RANGE, 0);
				
		ActiveElement player2 = new ActiveElement(2,"Rey","images/player/hero.png");
		player2.setProperty(ActiveElement.MOV_SPEED, 0.1);
		player2.setProperty(ActiveElement.RUN_SPEED, 0.1);
		player2.setProperty(ActiveElement.SIG_RANGE, 200);
		player2.setProperty(ActiveElement.ATT_RANGE, 0);
		
		elementPlayers.put(player1.getElementId(), player1);
		elementPlayers.put(player2.getElementId(), player2);
		
		elementBots.put(bot1.getElementId(), bot1);
		elementBots.put(bot2.getElementId(), bot2);
		elementBots.put(bot3.getElementId(), bot3);
	}	
	
	public static String[][] getMapDecription(){
		return mapDescription;
	}
	
	public static Map<Long, ActiveElement> getBotDecription(){
		return elementBots;
	}
	
	public static ActiveElement getElementPlayer(long id){
		return elementPlayers.get(id);
	}
	
	public static ActiveElement getElementBot(long id){
		return elementBots.get(id);
	}
	
	
	
}
